package com.xckj.cycling.dialog

import android.Manifest
import android.os.Bundle
import android.view.ViewGroup
import com.tbruyelle.rxpermissions3.RxPermissions
import com.xckj.cycling.activity.EditHeadActivity
import com.xckj.cycling.databinding.DialogEditHeadBinding

class EditHeadDialog(private val context: EditHeadActivity) : BaseDialog(context) {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val vb = DialogEditHeadBinding.inflate(
            layoutInflater,
            window?.decorView as ViewGroup?, false
        )
        setContentView(vb.root)
        vb.cancelAction.setOnClickListener {
            dismiss()
        }
        vb.camera.setOnClickListener {
            RxPermissions(context).requestEachCombined(Manifest.permission.CAMERA).subscribe {
                if (it.granted) {
                    context.camera()
                    dismiss()
                } else {
                    context.showMessage("no camera permission")
                }
            }
        }
        vb.gallery.setOnClickListener {
            context.gallery()
            dismiss()
        }

    }
}